# 导入模块
from flask.blueprints import Blueprint

# 继承重写后原有的Api就不需要了
# from flask_restful import Api
from toutiaoapi.flaskrestful import BaseApi


# 1. 创建蓝图
home_blueprint = Blueprint("home",__name__,url_prefix="/app/v1_0")

# 2. 创建Api接管蓝图
home_api = BaseApi(home_blueprint)

# 3. 定义类视图
from . import views,detail,comments,centers

# 4. 让api实例 绑定类视图路由
home_api.add_resource(views.IndexResource,"/articles")
# 获取所有频道
home_api.add_resource(views.AllChannelResource,"/channels")
# 用户频道
home_api.add_resource(views.UserChannelResource,"/user/channels")
# 文章详情
home_api.add_resource(detail.DetailResource,"/articles/<article_id>")
# 关注用户
home_api.add_resource(detail.UserFollowingResource,'/user/followings')
# 取消观众足用户
home_api.add_resource(detail.UserNotFollowingResource,'/user/followings/<target>')
# 点赞
home_api.add_resource(detail.UserArticleLikesResource,'/article/likings')
# 取消点赞
home_api.add_resource(detail.UserArticleLikesDeleteResource,'/article/likings/<target>')
# 不喜欢
home_api.add_resource(detail.UserArticleDislikesResource,'/article/dislikes')
# 取消不喜欢
home_api.add_resource(detail.UserArticleDislikesDeleteResource,'/article/dislikes/<target>')
# 收藏文章
home_api.add_resource(detail.UserCollectionsResource,'/article/collections')
# 取消收藏文章
home_api.add_resource(detail.UserCollectDeleteResource,'/article/collections/<target>')
# 发表评论
home_api.add_resource(comments.CommentsResourve,'/comments')
# 点赞评论
home_api.add_resource(comments.CommentLikesResource,'/comment/likings')
# 用户浏览记录
home_api.add_resource(centers.UserHistoryResourve,'/user/histories')
# 最后在toutiao的init中注册蓝图